﻿
SET QUOTED_IDENTIFIER ON
GO

SET ANSI_NULLS ON
GO

CREATE TABLE [dbo].[UDS_WorkAttendence_Data] (
    [WorkDate]       datetime NOT NULL,
    [DayValue]		 as (dbo.fn_GetDayValue(WorkDate)) PERSISTED,
    [StaffID]        int      NOT NULL,
    [OnDuty]         datetime NULL,
    [OffDuty]        datetime NULL,
    [OnDuty_Status]  bit      NULL,
    [OffDuty_Status] bit      NULL CONSTRAINT [DF_UDS_WorkAttendence_Data_OffDuty_Status] default(1),
    [OnDuty_MemoID]  bigint   NULL,
    [OffDuty_MemoID] bigint   NULL,
    [ID]             bigint   NOT NULL identity(1, 1),

    CONSTRAINT [PK_UDS_WorkAttendence_Data] PRIMARY KEY NONCLUSTERED ([ID] asc),
    CONSTRAINT [FK_UDS_WorkAttendence_Data_StaffID] FOREIGN KEY (StaffID) REFERENCES dbo.UDS_Staff (Staff_ID)
);
CREATE UNIQUE CLUSTERED INDEX [IX_UDS_WorkAttendence_Data_Staff_DayValue] ON dbo.UDS_WorkAttendence_Data ( StaffID asc, DayValue asc);
GO
